import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex);

const store = new Vuex.Store({
	state:{
		user: {},
		baseUrl: ''
	},
	mutations: {
		// 同步操作
		setUser(state, payload) {
			state.user = payload;
		},
		setBaseUrl(state, payload) {
			state.baseUrl = payload;
		}
	},
	actions: {
		// 这里为异步操作
		setUser({commit}, payload) {
			commit('setUser', payload);
		},
		setBaseUrl({commit}, payload) {
			commit('setBaseUrl', payload);
		}
	}
})

export default store;